package com.szrt.day20170424.ch02;


import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

import org.junit.Test;

public class PropertiesTest {
	
	@Test
	public void propertiesTest() throws Exception {
		
		
		
		//侦察兵
		File  file  = new File("src/config/jdbc.properties");
		
		//小部队
		InputStream  is = new FileInputStream(file);
		
		//大部队
		Properties p = new Properties();
		p.load(is);
		
		//crm.username 绝对是固定不变的。 但是 它对应的值可以随时修改  优势
		String username = p.getProperty("crm.username");
		//System.out.println(username);
		
		String password = p.getProperty("crm.password");
		//System.out.println(password);
		
		
		//如何遍历
		
		Set<Object> keySet = p.keySet();
		
		Iterator<Object> iterator = keySet.iterator();
		
		while(iterator.hasNext()){
			Object key = iterator.next();
			Object value = p.get(key);
			System.out.println(key+"="+value);
		}
		
		
	}

}
